package com.qt.socket.tcpwork.work3;

import java.io.*;
import java.net.Socket;

/**
 * @Author zsf
 * @Date 2023/10/5 17:04
 * @Version 1.0
 */
public class ClientDemo {
    /**
     * /客户端:将本地文件上传到服务器。接收服务器的反馈。
     * //服务器:接收客户端上传的文件,上传完毕之后给出反馈。
     */
    public static void main(String[] args) throws IOException {

        Socket socket = new Socket("127.0.0.1", 8888);

        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());

        FileInputStream fis = new FileInputStream("aaa\\a.txt");
        int len;
        byte[] bytes = new byte[1024];
        while ((len = fis.read(bytes)) != -1){
            bos.write(bytes,0,len);
        }

        //结束标记
        socket.shutdownOutput();

        //接收反馈
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String str = br.readLine();
        System.out.println(str);

        fis.close();
        socket.close();

    }
}
